<template>
    <div class="pad">
        <!-- table start -->
        <tableDataEl
            :page.sync="page"
            :pageSize.sync="pageSize"
            :tableData="tableData.list"
            :tableLabel="tableLabel"
            :pageCount="tableData.rows"
            v-loading="loading"
            height="88vh"
            @handleDetail="handleDetail"
        />
        <!-- table end -->

        <!-- dialog stat -->
        <el-dialog
            :visible.sync="isShowDetail"
            title="物料详情"
            center
            width="40%"
            top="10vh"
            v-el-drag-dialog
        >
            <div v-loading="detailLoading">
                <el-form label-width="100px" label-position="left">
                    <el-form-item label="维修厂名称">
                        {{detailData['company']}}
                    </el-form-item>
                    <el-form-item label="维修厂电话">
                        {{detailData['phone']}}
                    </el-form-item>
                    <el-form-item label="详细地址">
                        {{detailData['province']}}{{detailData['city']}}{{detailData['county']}}
                    </el-form-item>
                    <el-form-item label="设置供应商">
                        <el-input type="text" :value="gysArray" disabled  style="width:50%;"/>
                    </el-form-item>
                </el-form>
                <el-table
                        border
                        :data="detailData.detail"
                        style="margin-top:20px;"
                        height="250"
                >
                    <el-table-column
                            label="物料名称"
                            prop="materiel"
                            align="center"
                    />
                    <el-table-column
                            label="数量"
                            prop="num"
                            align="center"
                    />
                    <el-table-column
                            label="备注"
                            prop="remarks"
                            align="center"
                    />
                </el-table>
            </div>
        </el-dialog>
        <!-- dialog end -->
    </div>
</template>

<script>
    import tableDataEl from '@/views/Setup/common/table'
    export default {
        name: "throughdownList",
        components: {
            tableDataEl
        },
        data () {
            return {
                page: 1,
                pageSize: 8,
                tableData: {},
                tableLabel: [
                    {
                        label: '维修厂名称',
                        prop: 'company'
                    },
                    {
                        label: '负责人',
                        prop: 'leader'
                    },
                    {
                        label: '联系方式',
                        prop: 'phone'
                    },
                    {
                        label: '申请时间',
                        prop: 'create_time'
                    },
                    {
                        label: '审核时间',
                        prop: 'audit_time'
                    },
                    {
                        label: '详情',
                        detail: true,
                        btnText: '查看',
                        methodName: 'handleDetail'
                    }
                ],
                loading: false,
                isShowDetail: false,
                detailData: {},
                detailLoading: false,
                gysArray: ''
            }
        },
        methods: {
            async init () {
                this.loading = true;
                let res = await this.api.admin_b_lbPassList({page: this.page, pageSize: this.pageSize});
                res.code ? this.tableData = res.data : this.$message(res.msg);
                this.loading = false;
            },
            async handleDetail(...value) {
                this.isShowDetail = true;
                this.detailLoading = true;
                let res = await this.api.detail({id: value[1]['id']});
                res.code ? this.detailData = res.data.list : this.$message(res.msg);
                this.gysArray = res.data.gid_array[0]['name'];
                this.detailLoading = false;
            }

        },
        mounted () {
            this.init();
        },
        watch: {
            page () {
                this.init();
            },
            pageSize () {
                this.init();
            }
        }
    }
</script>

<style scoped>
    .pad {
        padding:10px;
    }
</style>
